package com.jinshan.edu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jinshan.edu.entity.EduTeacher;
import com.jinshan.edu.mapper.EduTeacherMapper;
import com.jinshan.edu.service.EduTeacherService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jinshan.request.QueryTeacherCondition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 讲师 服务实现类
 * </p>
 *
 * @author Jinshan
 * @since 2020-06-21
 */
@Service
public class EduTeacherServiceImpl extends ServiceImpl<EduTeacherMapper, EduTeacher> implements EduTeacherService {
    @Autowired
    private EduTeacherMapper eduTeacherMapper;

    @Override
    public void queryTeacherByCondition(Page<EduTeacher> teacherPage, QueryTeacherCondition queryTeacherCondition) {
        QueryWrapper<EduTeacher> wrapper = new QueryWrapper<>();
        String name = queryTeacherCondition.getName();
        Integer level = queryTeacherCondition.getLevel();
        String startTime = queryTeacherCondition.getStartTime();
        String endTime = queryTeacherCondition.getEndTime();
        if (name != null) {
            wrapper.like("name", name);
        }
        if (level != null) {
            wrapper.eq("level", level);
        }
        if (startTime != null) {
            wrapper.ge("gmt_create", startTime);
        }
        if (endTime != null) {
            wrapper.le("gmt_create", endTime);
        }
        eduTeacherMapper.selectPage(teacherPage, wrapper);
    }
}
